Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
![listhen](https://user-images.githubusercontent.com/904724/101662837-46845280-3a4a-11eb-9e9a-d5399e8af753.png)
Elegant http listener
✔️ Promisified interface for listening and closing server
✔️ Works with express/connect or plain http handle function
✔️ Support HTTP and HTTPS
✔️ Automatically assign a port or fallback to human friendly alternative (with get-port-please)
✔️ Automatically generate listening URL and show on console
✔️ Automatically copy URL to clipboard
✔️ Automatically open in browser (opt-in)
✔️ Automatically generate self signed certificate
✔️ Automatically detect test and production environments
✔️ Automatically close on exit signal
✔️ Gracefully shutdown server with http-shutdown
Install using npm or yarn:
npm i listhen
# or
yarn add listhen
Import into your Node.js project:
// CommonJS
const { listen } = require('listhen')
// ESM
import { listen } from 'listhen'
Function signature:
const { url, getURL, server, close } = await listen(handle, options?)
Plain handle function:
listen((_req, res) => {
res.end('hi')
})
With express/connect:
const express = require('express')
const app = express()
app.use('/', ((_req, res) => {
res.end('hi')
})
listen(app)
port
process.env.PORT
or 3000 or memorized random (see get-port-please)Port to listen.
hostname
process.env.HOST || '0.0.0.0'
Default hostname to listen.
https
false
Listen with https
protocol. By default uses a self-signed certificated.
certificate
Path to https certificate files { key, cert }
selfsigned
Options for self-signed certificate (see selfsigned).
showURL
true
(force disabled on test environment)Show a CLI message for listening URL.
baseURL
/
open
false
(force disabled on test and production environments)Open URL in browser. Silently ignores errors.
clipboard
false
(force disabled on test and production environments)Copy URL to clipboard. Silently ignores errors.
isTest
process.env.NODE_ENV === 'test'
Detect if running in a test environment to disable some features.
autoClose
true
Automatically close when an exit signal is received on process.
MIT. Made with 💖
FAQs
👂 Elegant HTTP Listener
The npm package listhen receives a total of 792,986 weekly downloads. As such, listhen popularity was classified as popular.
We found that listhen demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.